function calc(func) {
    var result = document.getElementById('result');
    var number1 = parseInt(document.getElementById('num1').value);
    var number2 = parseInt(document.getElementById('num1').value);
    if (isNaN(number1) || isNaN(number2)) {
        alert('请输入数字：');
        return false;
    }
    result.value = func(number1, number2);
}

function add(number1, number2) {
    return number1 + number2;
}

function sub(number1, number2) {
    return number1 - number2;
}

function mul(number1, number2) {
    return number1 * number2;
}

function div(number1, number2) {
    if (number2 === 0) {
        alert('除数不能为0');
        return '';
    }
    return number1 / number2;
}